package com.example.controller;

import com.example.bean.Person;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

@Controller
public class PersonController {

    @RequestMapping("/")
    public String index(Model model) {
        List<Person> list = new ArrayList<>();
        Person person = new Person();
        person.setName("dali");
        person.setAge(12);

        for(int i=0;i<5;i++) {
            Person person1 = new Person();
            person1.setName("dali"+i);
            person1.setAge(i);
            list.add(person1);
        }
        model.addAttribute("list",list);
        model.addAttribute("singlePerson",person);
        return "index";
    }
}
